<!DOCTYPE html>
<html lang="en">
<head>
  <!-- Required meta tags -->
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
        <title>库存管理系统</title>
        <!-- plugins:css -->
        <link rel="stylesheet" href="/static/vendors/mdi/css/materialdesignicons.min.css">
        <link rel="stylesheet" href="/static/vendors/base/vendor.bundle.base.css">
        <!-- endinject -->
        <!-- plugin css for this page -->
        <link rel="stylesheet" href="/static/vendors/datatables.net-bs4/dataTables.bootstrap4.css">
        <!-- End plugin css for this page -->
        <!-- inject:css -->
        <link rel="stylesheet" href="/static/css/style.css">
        <!-- endinject -->
        <link rel="shortcut icon" href="/static/images/favicon.png" />
</head>
<body>

  <div class="row stretch-card"><!--库存盘点，从数据库拉取，盘点可以考虑简化为重新抓取数据进行表格刷新-->
    <div class="card">
      <div class="card-body">
          <form method="POST" action="{% url 'warehouse:get_inv' %}">
              {% csrf_token %}
        <h class="card-title">库存盘点信息表</h>
            <button type="button" class="btn btn-primary btn-rounded btn-sm" onclick="displayResult()">获取数据</button>
              <input type="submit" class="btn btn-info btn-rounded btn-sm" value="计算盈亏">
        <div class="table-responsive pt-3">
          <table class="table table-dark" id="stock_inv_table">
            <thead>
              <tr>
                <th>#</th>
                <th>商品品名</th>
                <th>商品代码</th>
                <th>系统记录量</th>
                <th>实际库存量</th>
                <th>盘盈/盘亏</th>
              </tr>
            </thead>
            <tbody>
                {% for item in stock_inv_list %}
              <tr class="table-info">
                <td >{{forloop.counter}}</td>
                <td>{{item.goods.goods_id}}</td>
                <td>{{item.goods_name}}</td>
                <td>{{item.stock_num_system}}</td>
                <td class="center"><input type="number" value='' style="width:100px" class="spare_part_V"/></td>
                <td>{{item.stock_num_diff}}</td>
              </tr>
                {% endfor %}
            </tbody>
          </table>
        </div>
              </form>
      </div>
    </div>
  </div>

<script>
function displayResult(){
    var stock_table = document.getElementById('stock_inv_table');
    var row_list = stock_table.rows;
    for(var i=1;i<row_list.length;i++){
	    stock_table.rows[i].cells[4].childNodes[0].name=""+i;
	}
	alert("成功获取数据");
}
</script>
</body>
</html>